<template>
  <div class="search_page">
    <form action="/">
      <van-search
        v-model="value"
        show-action
        placeholder="请输入搜索关键词"
        @search="onsearch"
        @cancel="$router.push('/sale')"
      />
    </form>
    <div>
      <span v-for="item in list" :key="item" @click="btn(item.communityName)">{{
        item.communityName
      }}</span>
    </div>
  </div>
</template>
<script>
import { houseCommunity } from '@/api/house'
export default {
  name: 'search_page',
  data () {
    return {
      value: '',
      list: [],
      queryObj: {
        name: '',
        id: ''
      }
    }
  },
  methods: {
    async onsearch () {
      console.log(this.value)
      this.queryObj.name = this.value
      this.queryObj.id = 'AREA|88cff55c-aaa4-e2e0'
      const data = await houseCommunity(this.queryObj)
      console.log(data)
      this.list = data.body
    },
    btn (data) {
      this.$router.push({
        path: '/sale',
        query: { data }
      })
    }
  }
}
</script>
<style lang="less" scoped></style>
